<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html><html lang="en">
	<head>
		<!--加载header文件-->
		<?php
		include_once 'public/views/header.php';
		?>
		<link rel="stylesheet" href="public/css/list.css" />
		<link rel="stylesheet" href="public/xr/xrDatatable.css" />
		<script src="public/xr/xrDatatable.js?v=20231124"></script>
        <script src="public/js/list.js"></script>
		<!-- <script src="cust/js/articleList.js"></script> -->
	</head>  
	<body> 
		<div class="page-container container">
			<div class="searchForm">
			    <div class="searchForm-title"><i class="icon-table searchForm-title-icon"></i>数据表格<i class="icon-double-angle-up searchFormTitleIcon"></i></div>
			    <div class="searchForm-main">

					<form id="searchForm">
<!--                        <input type="hidden" name="role" value="--><?php //=$role?><!--">-->
							<input style="width:30%;" type="text" name='param' id="param" placeholder="标题"/>
							<select name="type" id="type">
							<option value="-1">请选择类型</option>
							<?php foreach ((new ImageType())->getAll() as $k => $v): ?>
                                <option <?php echo isset($type) && $type == $v[XPHEnum::Value] ? 'selected' : '' ?> value="<?php echo $v[XPHEnum::Value]; ?>"><?php echo $v[XPHEnum::Caption]; ?></option>
                            <?php endforeach; ?>
							</select>
					</form>
				</div>
			</div>
			<div class="listcontent">
				<div class='xrTableRow'>
					<table id="table" class="xrTable">
						<thead>
							<tr>
								<th name="_xrno"></th>
								<th name="_oper" style="width: 80px;">操作</th>
								<th name="_title" > 标题 </th>
								<th name="_typeChar" > 类型 </th>
								<th name="_createdChar" > 创建时间 </th>
							</tr>
						</thead>
					</table>
				</div>
			</div>
		</div>
		
	</body>
	<script>
		$("body").keydown(function() {
             if (event.keyCode == "13") {//keyCode=13是回车键
                 $('.searchButton').click();
             }
         });
		$("#type").change(function(){
			$('.searchButton').click();
		});

		$(function() {


			//初始化datatable
			$("#table").XRDataTable({
				ajaxUrl: "Admin/IndexLarge/imagetext_getDatas",
				paramFunc: paramFunc,
				operation: {
					"icon-list": [detailFunc,"查看信息"],
					// "icon-trash": [deleteFunc,'删除'],
					// "icon-refresh": [changeStatus, "发布/隐藏"]
				},
				hasCheckbox: false 
			});

			// exportEvent(); 
		}); 

		var paramFunc = function() { 
			var data = getFormJson();
			return data; 
		};

        var detailFunc = function(idx, trData) {


            if(trData.type == 1 || trData.type == 2) {

                window.open("Admin/HomeLarge/detail/"+trData.id+"/"+trData.type);
            } else {

                window.open('<?php echo base_url() ?>'+trData.file_url);
            }
            /*
            var msg = "是否确认删除【" + trData.title + "】?";
            swal({
                title: "请确认",
                text: msg,
                type: "warning",
                showCancelButton: true,
                closeOnConfirm: true,
                confirmButtonText: "确定",
                cancelButtonText: '取消',
                confirmButtonColor: "#ec6c62"
            }, function(isConfirm) {
                if(isConfirm) {
                    $.ajax({
                        type: "post",
                        url: "Admin/IndexLarge/imagetext_delete/"+trData.id,
                        async: true,
                        success: function(data) {
                            var ret = $.parseJSON(data);
                            if(ret.status) {
                                window.parent.topMessagePrompt('success',ret.msg);
                                window.parent.refreshTable();
                            } else {
                                window.parent.topMessagePrompt('error',ret.msg);
                            }
                        }
                    });
                }
            });*/
        };

		// var changeStatus = function(idx, trData) {
		// 	var msg = "";
		// 	if(trData.status == 1) {
		// 		msg = "是否确认影藏【" + trData.title + "】?";
		// 	} else {
		// 		msg = "是否确认发布【" + trData.title + "】?";
		// 	}
		// 	swal({
		// 		title: "请确认",
		// 		text: msg,
		// 		type: "warning",
		// 		showCancelButton: true,
		// 		closeOnConfirm: true,
		// 		confirmButtonText: "确定",
		// 		cancelButtonText: '取消',
		// 		confirmButtonColor: "#ec6c62"
		// 	}, function(isConfirm) {
		// 		if(isConfirm) {
		// 			$.ajax({
		// 				type: "post",
		// 				url: "Admin/IndexLarge/changeStatus/"+trData.id+"/"+trData.status,
		// 				async: true,
		// 				success: function(data) {
		// 					var ret = $.parseJSON(data);
		// 					if(ret.status) {
		// 						window.parent.topMessagePrompt('success',ret.msg);
		// 						window.parent.refreshTable();
		// 					} else {
		// 						window.parent.topMessagePrompt('error',ret.msg);
		// 					}
		// 				}
		// 			});
		// 		}
		// 	});
		// };


		// //导出数据
		// exportEvent = function() {
		// 	$("input").keypress(function(event) {
		// 		if(event.keyCode == "13") {
		// 			$("#table").search();
		// 		}
		// 	})
		// 	$("#export").click(function() {
		// 		var ret = $("#table").getTableThInfo();
		// 		ret.params = usefulArray(paramFunc());
		// 		ret.title = "会员列表";
		// 		locationPost("User/commonExport", {
		// 			'json': JSON.stringify(ret)
		// 		});
		// 	});
		// };
	</script>
</html>